package com.itheima.leyou.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leyou.item.dto.BrandDTO;
import com.itheima.leyou.po.Brand;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface BrandMapper  extends BaseMapper<Brand> {
    @Select("select * from tb_brand where id=#{id}")
    BrandDTO queryBrandById(@Param("id") Long id);

    @Insert("insert into tb_category_brand values(#{id},#{categoryId})")
    Boolean add(@Param("id") Long id, @Param("categoryId") Long categoryId);

    @Update("update tb_brand set image='' where id =#{bid}")
    void deleteByBrandId(@Param("bid") Long bid);


    //@Select("SELECT b.id, b.name, b.letter, b.image FROM tb_category_brand cb INNER JOIN tb_brand b ON b.id = cb.brand_id WHERE cb.category_id = #{cid}")
    //List<Brand> queryByCategoryId(@Param("cid") Long cid);
}
